<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
	<th:block th:include="include :: header('泵站详情')" />
</head>
<body>
    <div class="form-content form-horizontal">
    <input name="stationId" autocomplete="off" id="psId"  class="form-control" type="hidden"  th:value="${stationId}"/>
    		<div class="row">
    			<div class="col-sm-12">
    				<div class="form-group">
                 		<label class="col-sm-2 control-label"><span style="color: red; ">*</span>泵站名称：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input class="form-control" type="text" name="stationName"  id="stationName" th:value="${stationName}" readonly="readonly"/>
                            	<!-- <span class="input-group-addon"><i class="fa fa-search"></i></span> -->
                            </div>
                        </div>
             		</div>
             	</div>
    		</div>
    
    	<div class="row">
    		<div class="col-sm-12" style="margin-top: 15px;">
		    	
				<table id="rela-user-table" data-mobile-responsive="true"></table>
    		</div>
    	</div>
	</div>
    <div th:include="include::footer"></div>
    <script th:inline="javascript">
    	var prefix = ctx + "biz/stationUserRelation";
    	var editFlag = [[${@permission.hasPermi('biz:suredit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:sur:remove')}]];
        var types = [[${@dict.getType('biz_is_valid')}]];
        var datas = [[${@dict.getType('biz_is_delete')}]];
        
        
        function selectPumpStation() {
        	var psId = $("#psId").val();
            var url = ctx + "biz/pumpStation/selectPumpStation";
		    var options = {
				title: '选择泵站',
				width: "380",
				url: url,
				callBack: doPumpStationSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doPumpStationSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = layer.getChildFrame('body', index);
			$("#psId").val(body.find('#psId').val());
			$("#stationName").val(body.find('#stationName').val());
			layer.close(index);
		}
        
        
        $(function() {
            var options = {
            	id: "rela-user-table",
                url: ctx + "system/user/list",
                modalName: "泵站与用户关系管理",
                columns: [
                	{
     		            checkbox: true
     		        },
     				{
     					field : 'userId', 
     					title : '用户ID' 
     				},
				{
					field : 'userName', 
					title : '管理者名称' 
				},
				{
					field : 'loginName', 
					title : '登入名' 
				},
				{
					field : 'phoneNumber', 
					title : '管理者手机' 
				},
				{
					field : 'createBy', 
					title : '创建者' 
				},
				{
		            field: 'createTime',
		            title: '创建时间',
		            sortable: false
		        },
		        {
		            field: 'remark',
		            title: '备注'
		        }]
            };
            $.table.init(options);
        });
        
        
        
        
        function submitHandler() {
        	var firstColumn = $.table.selectFirstColumns();
        	var stationId = $('#psId').val();
        	if( stationId == null || stationId == ''){
        		$.modal.alertError("泵站未选择");
        		return;
        	}
        	if( firstColumn == null || firstColumn == ''){
        		$.modal.alertError("用户未选择");
        		return;
        	}
        	$.modal.confirm("确认要绑定吗？", function() {
				//$.operate.post(prefix + "/bindStationUsers", { "stationId": stationId, "firstColumn": firstColumn.toString() });
        		$.operate.save(prefix + "/bindStationUsers?stationId="+stationId+"&firstColumn="+firstColumn.toString(), '');
        	})
	    }
        
		function statusTools(row) {
		    if (row.isValid == 0) {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
    		} else {
    			return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
    		}
		}
		
		function disable(id) {
			$.modal.confirm("确认要失效吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
		    })
		}

		function enable(id) {
			$.modal.confirm("确认要启用吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
		    })
		}
         
      
    </script>
</body>
</html>
